<template>
  <div class="app-container">
    <div class="custom_card">
      <Tabs
        :list="tabs_list"
        :column="8"
        :minWidth="150"
        :active="active"
        @tabs_click="secondedTypeChange"
      ></Tabs>
    </div>
    <div class="custom_card_0" v-show="showSearch">
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        label-width="68px"
      >
        <el-form-item label="支出时间" prop="time">
          <el-date-picker
            clearable
            size="small"
            v-model="queryParams.time"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            placeholder="选择支出时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['bills:reimbursement:add']"
          >新增</el-button
          >
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            :loading="exportLoading"
            @click="handleExport"
            v-hasPermi="['bills:reimbursement:export']"
          >导出</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div class="custom_card">
      <el-table v-loading="loading" :data="reimbursementList" border>
        <el-table-column
          label="支出时间"
          align="center"
          prop="reimbursementTime"
          min-width="160"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.reimbursementTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="财务状态"
          align="center"
          prop="settlementStatus"
          min-width="140"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.settlement_status"
              :value="scope.row.settlementStatus"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="成本类型"
          align="center"
          prop="reimbursementType"
          min-width="140"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.reimbursement_type"
              :value="scope.row.reimbursementType"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="支出金额"
          align="center"
          prop="reimbursementAmount"
          min-width="140"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            ¥{{ scope.row.reimbursementAmount }}
          </template>
        </el-table-column>
        <el-table-column
          label="经办人"
          align="center"
          prop="userName"
          min-width="140"
          show-overflow-tooltip
        />
        <el-table-column
          label="操作"
          align="center"
          width="200"
          fixed="left"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['bills:reimbursement:edit']"
              >修改</el-button
            >
            <el-button size="mini" type="text" @click="handleDelete(scope.row)" v-hasPermi="['bills:reimbursement:delete']"
              >删除</el-button
            >
            <el-button size="mini" type="text" @click="handleShow(scope.row)"
              >费用明细</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <el-dialog
      title="新增成本"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="cancelDialogVisible"
    >
      <el-form ref="form1" :model="form1" :rules="rules" label-width="100px">
        <el-form-item label="成本类型" prop="reimbursementType">
          <el-radio-group v-model="form1.reimbursementType" size="medium">
            <el-radio
              style="line-height: 3"
              v-for="dict in dict.type.reimbursement_type"
              :label="parseInt(dict.value)"
              :value="parseInt(dict.value)"
              :key="parseInt(dict.value)"
              >{{ dict.label }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancelDialogVisible">取 消</el-button>
        <el-button type="primary" @click="addCouponManage">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 添加或修改费用报销对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      append-to-body
      :close-on-click-modal="false"
      width="700px"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row>
          <el-col :span="12" style="height: 58px; overflow: hidden">
            <el-form-item label="成本类型" prop="reimbursementType">
              <el-select
                v-model="form.reimbursementType"
                placeholder="请选择成本类型"
                clearable
                size="small"
                style="width: 100%"
                disabled
              >
                <el-option
                  v-for="dict in dict.type.reimbursement_type"
                  :key="parseInt(dict.value)"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.reimbursementType == 6">
            <el-form-item label="油卡" prop="cardNo">
              <el-input v-model="form.cardNo" disabled placeholder="请选择油卡">
                <el-button slot="append" v-if="form.id == null"
                  ><span @click="selectBizNo">选择</span></el-button
                >
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.reimbursementType == 6 && form.cardNo">
            <el-form-item label="油卡公司" prop="bizNo">
              <el-input v-model="form.cardCompanyName" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.reimbursementType == 6 && form.cardNo">
            <el-form-item label="当前金额" prop="bizNo">
              <el-input v-model="form.balance" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.reimbursementType == 5">
            <el-form-item label="报销事项" prop="reimbursementMatter">
              <el-select
                v-model="form.reimbursementMatter"
                placeholder="请选择报销事项"
                clearable
                size="small"
              >
                <el-option
                  v-for="dict in dict.type.reimbursement_matter"
                  :key="parseInt(dict.value)"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              :label="reimbursementTimeLabel"
              prop="reimbursementTime"
            >
              <el-date-picker
                clearable
                size="small"
                v-model="form.reimbursementTime"
                type="datetime"
                style="width: 100%"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择报销日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              :label="reimbursementAmountLabel"
              prop="reimbursementAmount"
            >
              <el-input
                v-model="form.reimbursementAmount"
                placeholder="请输入金额"
                maxlength="10"
                show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="form.reimbursementType != 6">
            <el-form-item label="备注" prop="remark">
              <el-input
                v-model="form.remark"
                type="textarea"
                placeholder="请输入备注"
                maxlength="200"
                show-word-limit
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="凭证" prop="costImage">
              <ImageUpload
                @on-success="costImageSuccess"
                v-model="form.costImage"
                :limit="6"
                @on-remove="costImageRemove"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" :loading="submitLoading"
          >确 定</el-button
        >
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--详情-->
    <el-dialog
      title="费用明细"
      :visible.sync="openShow"
      append-to-body
      :close-on-click-modal="false"
      width="700px"
    >
      <el-row>
        <el-col :span="24">
          <el-descriptions
            :column="2"
            border
            :labelStyle="{ width: '120px' }"
            :contentStyle="{ width: '300px' }"
          >
            <el-descriptions-item label-class-name="my-descriptions-label" >
              <template slot="label">成本类型</template>
              <dict-tag
                :options="dict.type.reimbursement_type"
                :value="form.reimbursementType"
              />
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label"  v-if="form.reimbursementType == 6">
              <template slot="label">油卡</template>
              {{ form.cardNo }}
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label"  v-if="form.reimbursementType == 6">
              <template slot="label">油卡公司</template>
              {{ form.cardCompanyName }}
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label"  v-if="form.reimbursementType == 6">
              <template slot="label">余额</template>
              ¥{{ form.balance }}元
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label"  v-if="form.reimbursementType == 5">
              <template slot="label">报销事项</template>
              <dict-tag
                :options="dict.type.reimbursement_matter"
                :value="form.reimbursementMatter"
              />
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label" >
              <template slot="label">{{ reimbursementTimeLabel }}</template>
              {{ form.reimbursementTime }}
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label" >
              <template slot="label">{{ reimbursementAmountLabel }}</template>
              {{ form.reimbursementAmount }}元
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label"  v-if="form.reimbursementType != 6">
              <template slot="label">备注</template>
              {{ form.remark }}
            </el-descriptions-item>
            <el-descriptions-item label-class-name="my-descriptions-label"  :span="2">
              <template slot="label">凭证</template>
              <el-image
                v-for="(item, index) in form.urlList"
                :key="index"
                :src="getImgUrl(item)"
                :preview-src-list="[getImgUrl(item)]"
                style="width: 20%; margin-right: 15px"
                fit="contain"
              ></el-image>
            </el-descriptions-item>
          </el-descriptions>
        </el-col>
      </el-row>
    </el-dialog>
    <el-drawer
      title="油卡列表"
      :visible.sync="drawerFlagBizNo"
      :direction="directionBizNo"
      size="50%"
      :before-close="handleBizNoClose"
      :modal="false"
    >
      <div class="table-padding search">
        <el-form
          :model="queryParamsBizNo"
          ref="queryBizNoForm"
          :inline="true"
          label-width="40px"
        >
          <el-form-item label="卡号" prop="name">
            <el-input
              v-model="queryParamsBizNo.cardNo"
              placeholder="请输入卡号"
              clearable
              size="small"
              @keyup.enter.native="handleQueryBizNo"
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQueryBizNo"
              >搜索</el-button
            >
            <el-button
              icon="el-icon-refresh"
              size="mini"
              @click="resetQueryBizNo"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
        <el-table v-loading="loadingBizNoDrawer" :data="BizNoDrawerList" border>
          <el-table-column
            label="卡号"
            align="center"
            min-width="140"
            show-overflow-tooltip
            prop="cardNo"
          />
          <el-table-column
            label="油卡公司"
            align="center"
            min-width="140"
            show-overflow-tooltip
            prop="cardCompanyName"
          />
          <el-table-column
            label="当前余额"
            align="center"
            min-width="140"
            show-overflow-tooltip
            prop="balance"
          />

          <el-table-column
            label="操作"
            align="center"
            fixed="left"
            class-name="small-padding fixed-width"
            width="150px"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="handleBizNoUpdate(scope.row)"
                >选择</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="totalBizNo > 0"
          :total="totalBizNo"
          :page.sync="queryParamsBizNo.pageNum"
          :limit.sync="queryParamsBizNo.pageSize"
          @pagination="getBizNoList"
        />
      </div>
    </el-drawer>
  </div>
</template>

<script>
import {
  listReimbursement,
  billCount,
  billCount1,
  getReimbursement,
  delReimbursement,
  addReimbursement,
  updateReimbursement,
  exportReimbursement,
} from '@/api/bills/reimbursement'
import { listOilCard } from '@/api/car/oilCard'
import Tabs from '@/components/custom/tabs.vue'
export default {
  name: 'Reimbursement',
  dicts: [
    'settlement_way',
    'settlement_status',
    'secondments_state',
    'seconded_type',
    'reimbursement_matter',
    'reimbursement_type',
  ],
  data() {
    return {
      active: '',
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      dialogVisible: false,
      submitLoading: false,
      openShow: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      reimbursementTimeLabel: '报销日期',
      reimbursementAmountLabel: '报销金额',
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 费用报销表格数据
      reimbursementList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      tabs_list: [
        { key: '', name: '全部费用', count: '￥0' },
        { key: '1', name: '工资成本支出', count: '￥0' },
        { key: '2', name: '场地成本支出', count: '￥0' },
        { key: '3', name: '办公费用支出', count: '￥0' },
        { key: '5', name: '水电费用支出', count: '￥0' },
        { key: '6', name: '费用报销支出', count: '￥0' },
        { key: '7', name: '油卡成本支出', count: '￥0' },
        { key: '8', name: '其他费用支出', count: '￥0' },
      ],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        reimbursementMatter: null,
        reimbursementTime: null,
        reimbursementAmount: null,
        settlementStatus: null,
        deptId: null,
        tenantId: null,
        time: [],
        reimbursementType: null,
        startTime: null,
        endTime: null,
      },
      form1: {
        reimbursementType: 1,
      },
      // 表单参数
      form: {},
      formCount: {},
      drawerFlagBizNo: false,
      loadingBizNoDrawer: false,
      directionBizNo: 'rtl',
      BizNoDrawerList: [],
      totalBizNo: 0,

      queryParamsBizNo: {
        pageNum: 1,
        pageSize: 10,
        cardNo: null,
      },
      // 表单校验
      rules: {
        reimbursementMatter: [
          { required: true, message: '报销事项不能为空', trigger: 'blur' },
        ],
        cardNo: [{ required: true, message: '请选择油卡', trigger: 'change' }],
        reimbursementTime: [
          { required: true, message: '报销日期不能为空', trigger: 'blur' },
        ],
        estimateEndTime: [
          { required: true, message: '借调结束时间不能为空', trigger: 'blur' },
        ],
        reimbursementAmount: [
          { required: true, message: '支出费用不能为空', trigger: 'change' },
          {
            pattern: /^(([1-9][0-9]*)|(([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2})))$/,
            message: '费用输入有误',
            trigger: 'blur',
          },
        ],
      },
    }
  },
  components: {
    Tabs,
  },
  created() {
    this.getList()
    this.getBillCount()
  },
  methods: {
    secondedTypeChange(val) {
      // this.resetQuery()
      this.active = val
      this.queryParams.reimbursementType = val
      this.getList()
    },
    getBillCount1() {
      billCount1(this.queryParams).then((response) => {
        let carBill1 = response.data
        this.tabs_list = [
          { key: '', name: '全部费用', count: '￥' + this.formCount.allCount },
          { key: '1', name: '工资成本支出', count: '￥' + this.formCount.gz },
          { key: '2', name: '场地成本支出', count: '￥' + this.formCount.cd },
          { key: '3', name: '办公费用支出', count: '￥' + this.formCount.bg },
          { key: '4', name: '水电费用支出', count: '￥' + this.formCount.sd },
          { key: '5', name: '费用报销支出', count: '￥' + this.formCount.bx },
          { key: '6', name: '油卡成本支出', count: '￥' + this.formCount.yk },
          { key: '7', name: '其他费用支出', count: '￥' + this.formCount.qt },
        ]
        this.tabs_list.forEach(i=>{
          i.count = '￥' + carBill1.allCount;
          switch (parseInt(i.key)) {
            case 1:
              i.count = '￥' + carBill1.gz;
              break
            case 2:
              i.count = '￥' +  carBill1.cd;
              break
            case 3:
              i.count = '￥' + carBill1.bg;
              break
            case 4:
              i.count = '￥' +  carBill1.sd;
              break
            case 5:
              i.count = '￥' +  carBill1.bx;
              break
            case 6:
              i.count = '￥' +  carBill1.yk;
              break
            case 7:
              i.count = '￥' +  carBill1.qt;
              break
          }
         /* if(parseInt(i.key)==parseInt(this.queryParams.reimbursementType) || !this.queryParams.reimbursementType){
             }*/
        })
      })
    },

    getBillCount() {
      billCount(this.queryParams).then((response) => {
        let formCount = response.data
        this.formCount = response.data
        this.tabs_list = [
          { key: '', name: '全部费用', count: '￥' + formCount.allCount },
          { key: '1', name: '工资成本支出', count: '￥' + formCount.gz },
          { key: '2', name: '场地成本支出', count: '￥' + formCount.cd },
          { key: '3', name: '办公费用支出', count: '￥' + formCount.bg },
          { key: '4', name: '水电费用支出', count: '￥' + formCount.sd },
          { key: '5', name: '费用报销支出', count: '￥' + formCount.bx },
          { key: '6', name: '油卡成本支出', count: '￥' + formCount.yk },
          { key: '7', name: '其他费用支出', count: '￥' + formCount.qt },
        ]
      })
    },
    handleBizNoClose(done) {
      done()
    },
    selectBizNo() {
      this.drawerFlagBizNo = true
      this.getBizNoList()
    },
    handleQueryBizNo() {
      this.queryParamsBizNo.pageNum = 1
      this.getBizNoList()
    },
    /** 查询油卡列表 */
    getBizNoList() {
      this.loadingDrawer = true
      listOilCard(this.queryParamsBizNo).then((response) => {
        this.BizNoDrawerList = response.rows
        this.totalBizNo = response.total
        this.loadingDrawer = false
      })
    },
    /** 重置按钮操作 */
    resetQueryBizNo() {
      this.resetForm('queryBizNoForm')
      this.queryParamsBizNo.cardNo = null
      this.handleQueryBizNo()
    },
    //选择油卡
    handleBizNoUpdate(row) {
      this.form.bizNo = row.id
      this.form.cardNo = row.cardNo
      this.form.cardCompanyName = row.cardCompanyName
      this.form.balance = row.balance
      this.drawerFlagBizNo = false
    },
    updetailsImage(url) {
      this.form.costImage = url
    },
    // 删除门店图片
    costImageRemove(file) {
      this.form.costImage = null
    },
    // 上传成功门店回调
    costImageSuccess(res) {
      this.form.costImage = res.fileName
      this.$refs['form'].validateField('costImage')
    },
    addCouponManage() {
      this.$refs['form1'].validate((valid) => {
        if (valid) {
          let reimbursementType = this.form1.reimbursementType
          if (reimbursementType == 6) {
            this.reimbursementTimeLabel = '充值日期'
            this.reimbursementAmountLabel = '充值金额'
          } else if (reimbursementType == 5) {
            this.reimbursementTimeLabel = '报销日期'
            this.reimbursementAmountLabel = '报销金额'
          } else {
            this.reimbursementTimeLabel = '支出日期'
            this.reimbursementAmountLabel = '支出金额'
          }
          this.dialogVisible = false
          this.reset()
          this.form.reimbursementType = reimbursementType
          this.form.settlementWay = 1
          this.form.reimbursementTime = this.parseTime(
            new Date(),
            '{y}-{m}-{d} {h}:{i}:{s}'
          )
          this.open = true
        }
      })
    },
    cancelDialogVisible() {
      this.dialogVisible = false
      this.resetform1()
    },
    // 表单重置
    resetform1() {
      this.form1 = {
        reimbursementType: 1,
      }
      this.resetForm('form1')
    },
    /** 查询费用报销列表 */
    getList() {
      this.getBillCount1()
      this.loading = true
      listReimbursement(this.queryParams).then((response) => {
        this.reimbursementList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    cancelShow() {
      this.openShow = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        reimbursementMatter: null,
        reimbursementTime: null,
        reimbursementAmount: null,
        settlementStatus: 0,
        deptId: null,
        tenantId: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        costImage: null,
        urlList: [],
        time: null,
        bizNo: null,
        cardNo: null,
        reimbursementType: 1,
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      if (this.queryParams.time) {
        console.log(this.queryParams)
        this.queryParams.startTime = this.parseTime(
          this.queryParams.time[0],
          '{y}-{m}-{d} {h}:{i}:{s}'
        )
        this.queryParams.endTime = this.parseTime(
          this.queryParams.time[1],
          '{y}-{m}-{d} {h}:{i}:{s}'
        )
        console.log(this.queryParams)
      }else{
        this.queryParams.time=null;
        this.queryParams.startTime =null;
        this.queryParams.endTime =null;
      }

      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.time = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.dialogVisible = true
      this.title = '添加成本'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getReimbursement(id).then((response) => {
        this.form = response.data
        this.open = true
        this.title = '修改成本'
        if (this.form.urlList) {
          this.form.costImage = this.form.urlList.join(',')
          console.log(this.form.costImage)
        }
        if (this.form.reimbursementType == 6) {
          this.reimbursementTimeLabel = '充值日期'
          this.reimbursementAmountLabel = '充值金额'
        }else if (this.form.reimbursementType == 5) {
            this.reimbursementTimeLabel = '报销日期'
            this.reimbursementAmountLabel = '报销金额'
          } else {
            this.reimbursementTimeLabel = '支出日期'
            this.reimbursementAmountLabel = '支出金额'
          }
      })
    },
    handleShow(row) {
      const id = row.id
      getReimbursement(id).then((response) => {
        this.form = response.data
        if (this.form.urlList) {
          this.form.costImage = this.form.urlList.join(',')
          this.openShow = true
        }
        if (this.form.reimbursementType == 6) {
          this.reimbursementTimeLabel = '充值日期'
          this.reimbursementAmountLabel = '充值金额'
        }else if (this.form.reimbursementType == 5) {
            this.reimbursementTimeLabel = '报销日期'
            this.reimbursementAmountLabel = '报销金额'
          } else {
            this.reimbursementTimeLabel = '支出日期'
            this.reimbursementAmountLabel = '支出金额'
          }
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.submitLoading = true
          if (this.form.costImage) {
            this.form.urlList = this.form.costImage.split(',')
          }
          if (this.form.id != null) {
            updateReimbursement(this.form).then((response) => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.getList()
              this.getBillCount()
              this.submitLoading = false
            })
          } else {
            addReimbursement(this.form).then((response) => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.getList()
              this.getBillCount();
              this.submitLoading = false
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal
        .confirm('是否确认删除费用报销编号为"' + ids + '"的数据项？')
        .then(function () {
          return delReimbursement(ids)
        })
        .then(() => {
          this.getList()
          this.$modal.msgSuccess('删除成功')
        })
        .catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$modal
        .confirm('是否确认导出所有费用报销数据项？')
        .then(() => {
          this.exportLoading = true
          return exportReimbursement(queryParams)
        })
        .then((response) => {
          this.$download.name(response.msg)
          this.exportLoading = false
        })
        .catch(() => {})
    },
  },
}
</script>
